<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // document.write(Math.round(Math.random()*(10 )));
        // document.write(Math.max(5,));
        // 取5-10的随机数
        // document.write(Math.round(Math.random()*5)+5)

        // 点名系统
        let nameArray = ['james', 'allen', 'harward', 'rose', 'kelly']
        let isRest = true

        do {
            console.log(nameArray);

            if (nameArray.length === 0 || nameArray === null) {
                alert('班上的同学已经全部被点过名了！！！')
                isRest = false
            }
            else {
                alert('被点名的同事请回答老师的问题: ' + getNameFuntion(nameArray.length))
            }


        }
        while (isRest)

        function getNameFuntion(arrayLength) {
            let index = Math.floor(Math.random() * arrayLength)
            let name = nameArray[index]
            nameArray.splice(index, 1)
            return name
        }

    </script>
</body>

</html>